/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.lczyfz.wisdom.modules.platform.service;

import com.lczyfz.wisdom.common.persistence.Page;
import com.lczyfz.wisdom.common.service.CrudService;
import com.lczyfz.wisdom.common.utils.ResponseCode;
import com.lczyfz.wisdom.common.utils.ServerResponse;
import com.lczyfz.wisdom.modules.platform.dao.OpinionDao;
import com.lczyfz.wisdom.modules.platform.entity.Opinion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户反馈Service
 * @author css
 * @version 2019-09-26
 */
@Service
@Transactional(readOnly = true)
public class OpinionService extends CrudService<OpinionDao, Opinion> {


    @Autowired
    OpinionDao opinionDao;

	public Opinion get(String id) {
		return super.get(id);
	}
	
	public List<Opinion> findList(Opinion opinion) {
		return super.findList(opinion);
	}
	
	public Page<Opinion> findPage(Page<Opinion> page, Opinion opinion) {
		return super.findPage(page, opinion);
	}
	
	@Transactional(readOnly = false)
	public ServerResponse opinionSave(Opinion opinion) {
        if(null == opinion.getUserId() || "".equals(opinion.getUserId())){
			return new ServerResponse(-10000,"获取用户信息失败");
		}
		if(null == opinion.getOpinion() || "".equals(opinion.getOpinion())){
			return new ServerResponse(-10001,"请输入反馈内容");
		}
		super.save(opinion);
		return new ServerResponse(ResponseCode.SUCCESS.getCode(),"保存反馈成功");
	}

	@Transactional(readOnly = false)
	public void save(Opinion opinion) {
		super.save(opinion);
	}
	
	@Transactional(readOnly = false)
	public void delete(Opinion opinion) {
		super.delete(opinion);
	}
	
}